#include "MainHeader.h"

BOOL CALLBACK  SSProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){


	
	PAINTSTRUCT ps;
	HDC hdc;
	char buf[256];
	switch (message) 
	{
	case WM_INITDIALOG:
		hwndSS = hWnd;
		dispic=0;
		SFSS=0;
		break;
		
		
	case WM_LBUTTONDOWN:
		
		
		break;
	case WM_COMMAND:
		switch(LOWORD(wParam)){
			case cmdSSCancel:
                	ShowWindow(hWnd,SW_HIDE);
					return 0;
				break;
			case cmdPrev:
				if((dispic-1)<0) return 0;
				  dispic-=1;
				  sprintf(buf,"Sprite: %d",dispic);
				  SetWindowText(GetDlgItem(hWnd,lblSpriteblah),buf);
				  InvalidateRect(hwndSS,0,1);
				break;
			case cmdNext:
				if((dispic+1 >=maxsprite)) return 0;
				  dispic+=1;
				  sprintf(buf,"Sprite: %d",dispic);
				  SetWindowText(GetDlgItem(hWnd,lblSpriteblah),buf);
				  InvalidateRect(hwndSS,0,1);
				break;
			case cmdSSOk:
                 SetCurSprite();
				 DrawRoom();
                 ShowWindow(hWnd,SW_HIDE);
				break;
		
			case WM_DESTROY:
				ShowWindow(hWnd,SW_HIDE);
				break;	
	
		}
		break;
	case WM_VSCROLL:	// exact same idea, but V scroll instead of H scroll
		
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		
	
	
		//GetWindowRect(GetDlgItem(hWnd,fraSpriteSS),&sprdst);
       SpritePics[dispic].Blit(hdc,230,59,
	    	(OverallSize[dispic].right -OverallSize[dispic].left),	
	        (OverallSize[dispic].bottom-OverallSize[dispic].top),
			0,
			0);
	   	EndPaint(hWnd, &ps);
		break;
		case WM_SHOWWINDOW:
		 // LoadCurSprite();	
			break;
			
			
	}
	
//return DefWindowProc(hWnd, message, wParam, lParam);
	return 0;
}
int SetCurSprite(){
int beta; 
    switch(Combos[cSpriteSet].GetListIndex()){
			case  0:
				beta = Enemy1.Enemies[SFSS].Creature/0x10;
				Enemy1.Enemies[SFSS].Creature= beta*16 + dispic+1;
				//Enemy1.Enemies[SFSS].Creature=beta;
             
			   break;
            case 1:
				beta = Enemy2.Enemies[SFSS].Creature/0x10;
				Enemy2.Enemies[SFSS].Creature= beta*16 + dispic+1;
			   break;
			case 2:
			beta = Enemy2.Enemies[SFSS].Creature/0x10;
				Enemy2.Enemies[SFSS].Creature= beta*16 + dispic+1;
			   break;
	}
return 0;
}
int LoadCurSprite(){     //Sets dispic for starting.
    switch(Combos[cSpriteSet].GetListIndex()){
			case  0:
             dispic = ((Enemy1.Enemies[SFSS].Creature)&0xf)-1;
			   break;
            case 1:
				dispic = ((Enemy2.Enemies[SFSS].Creature)&0xf)-1;
			   break;
			case 2:
				dispic = ((Enemy3.Enemies[SFSS].Creature)&0xf)-1;
			   break;
	}
	
	return 0;
}
